def find_one_less_value(lst):
    """
    在数组中找到任意一个局部最小值：lst[i-1] < lst[i] < lst[i+1]
    :param lst:
    :return:
    """
    if not lst:
        return -1
    if len(lst) == 1 or lst[0] < lst[1]:
        return 0
    if lst[-1] < lst[-2]:
        return len(lst) - 1

    l = 1
    r = len(lst) - 2
    while l != r:
        mid = l + ((r - l) >> 1)
        if lst[mid] > lst[mid - 1]:
            r = mid
        elif lst[mid] > lst[mid + 1]:
            l = mid
        else:
            return mid

    return l


if __name__ == "__main__":
    lst = [10, 1, 7, 2, 5, 3, 7, 8]
    print(find_one_less_value(lst))
